// import { printUnitNum } from '@/views/permission/wipManagement/productionCenter/components/productionHomepage/options/jinchang/home/adjustingSetting/printUnit';

// import { numMap } from '@/views/permission/wipManagement/productionCenter/components/productionHomepage/options/utils';

const printUnitNum = 3;

const numMap = {1:'一',2:'二',3:'三'};

import addressList from './../../dataOptions/fins/jinchang/home';

const getAddressListFn = (plcId) => {
  let list = [];

  if (plcId && addressList && addressList.length) {
    list = addressList.filter(item => item.plcId === plcId);
  }

  return list;
}

// console.log(dfFinsAllReadList);

const printUnitList: any = [];

for (let i = 0; i < printUnitNum; i++) {
  const key = i + 1;

  printUnitList.push({
    name: `印刷${numMap[key]}单元plc`,
    nameEn: `${key}color`,
    plcId: `${key}color`,
    host: `192.168.250.1${key}`
  }); //印刷单元plc
}

const plcList = [
  {
    name: 'NJ主控',
    nameEn: 'NJ',
    plcId: 'NJ',
    host: '192.168.250.2'
  },
  {
    name: '送纸plc',
    nameEn: 'paperFeed',
    plcId: 'paperFeed',
    host: '192.168.250.3'
  },
  ...printUnitList,
  {
    name: '开槽plc',
    nameEn: 'slotting',
    plcId: 'slotting',
    host: '192.168.250.17'
  },
  {
    name: '开槽偏心plc',
    nameEn: 'slottingBias',
    plcId: 'slottingBias',
    host: '192.168.250.18'
  },
  {
    name: '模切plc',
    nameEn: 'dieCutting',
    plcId: 'dieCutting',
    host: '192.168.250.19'
  }
];

const setPlcListFn = () => {
  const newPlcList: any = [];

  for (const item of plcList) {
    newPlcList.push({
      ...item,
      protocol: 'udp', //tcp
      connectReadTime: 300,
      connectOverTime: 5000,
      reConnectNum: 5,
      connectType: 'fins',
      addressList: getAddressListFn(item.plcId)
    });
  }

  return newPlcList;
};

export default [
  ...setPlcListFn(),
  // {
  //   // ...item,
  //   name: '送纸plc',
  //   nameEn: 'paperFeed',
  //   plcId: 'paperFeed',
  //   host: '10.2.10.133',
  //   protocol: 'udp', //tcp
  //   connectReadTime: 300,
  //   connectOverTime: 5000,
  //   reConnectNum: 5,
  //   connectType: 'fins',
  //   addressList: dfFinsAllReadList.filter(item => item.plcId === 'paperFeed')
  // }
];
